const express = require('express')
const {
	list,
	add,
	modify,
	del,
	grantFuncs,
	funcs,
} = require('../modules/module-role')

const router = express.Router()

// /cms/role/list
router.post('/role/list', function(req, res, next) {
	return list(req).then(response => {
		return res.type('json').send(response)
	})
})

// /cms/role/add
router.post('/role/add', function(req, res, next) {
	return add(req).then(response => {
		return res.type('json').send(response)
	})
})

// /cms/role/modify
router.post('/role/modify', function(req, res, next) {
	return modify(req).then(response => {
		return res.type('json').send(response)
	})
})

// /cms/role/del
router.post('/role/del', function(req, res, next) {
	return del(req).then(response => {
		return res.type('json').send(response)
	})
})

// /cms/role/grant
router.post('/role/grant', function(req, res, next) {
	return grantFuncs(req).then(response => {
		return res.type('json').send(response)
	})
})

// /cms/role/funcs
router.post('/role/funcs', function(req, res, next) {
	return funcs(req).then(response => {
		return res.type('json').send(response)
	})
})

module.exports = router